<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>重庆大学硕士研究生服务系统</title>
<?php $this->load->view('includes/ga_head'); ?>  
</head>
<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> 
<body class=""> 
<!--<![endif]-->
<?php $this->load->view('includes/ga_navbar'); ?>  
<?php $this->load->view('includes/ga_sidebar'); ?>  
<div class="content">
    <div class="header">
        <h1 class="page-title">站内信会话</h1>
    </div>
    <ul class="breadcrumb">
            <li><a href="<?php echo $base_url;?>gass_news/all_public_news">Home</a> <span class="divider">/</span></li>
            <li class="active">
  			<?php
  			echo $recUserInfo['upro_first_name'].' '.$recUserInfo['upro_last_name'];
  			?>
            </li>
    </ul>
    <div class="container-fluid">
        <div class="row-fluid">
<?php $this->load->view('includes/ga_message'); ?>  
      <?php echo form_open(current_url());?> 
  <?php foreach ($messageList as $ml) { ?>
  <blockquote <?php echo ($ml['send_id']==$this->flexi_auth->get_user_id())?"class='span12 muted'":"class='pull-right span12 text-info'"; ?>>
  <small><?php echo $ml['creat_time'];?></small>
  <p><?php echo $ml['mess_content']; ?></p>
  </blockquote>
  <?php } ?>
      <?php echo form_close();?>
<div class="control-group">
    <label class="control-label" >内容</label>
    <div class="controls">
<textarea id = "sendMessageText" class="span4" rows="3"></textarea>
    </div>
</div>
<div class="control-group">
    <label class="control-label" ></label>
    <div class="controls">
   <input type="button" id = "send_button" value="发 送" disabled class="btn" /><input type="hidden" id="recId" value="<?php echo $recUserInfo['upro_id']; ?>" />
    </div>
</div>
<?php $this->load->view('includes/ga_footer'); ?>  
        </div>
    </div>
</div>
<?php $this->load->view('includes/ga_scripts'); ?>
<script>
$(function() {
    //对输入框的文字进行动态判断  
$( "input[type=button]" ).button().click(function( event ) {
    //响应click之后，button被disabled
    $( "#send_button" )[0].disabled=true;
      var sendMessageText = $("#sendMessageText").val();
      var recId = $("#recId").val();
			if (sendMessageText.length==0||sendMessageText.length>140){
				alert('信息长度有误，请控制在75个字以内！');
				return false;
			}      
      $.ajax({
         type:"post",
         data: "recId=" + recId + "&text=" + sendMessageText,
         url: "<?php echo base_url();?>gass_message/send_message",
         success: function(result){
             //$("#photoboard").fadeTo("slow", 0.85).fadeIn("normal").html(result);
             //alert("发送成功");
             //$( "#dialog-form" ).dialog( "close" );
             location.reload();
         },
         error: function(){
             //$("#loading_message").hide();
             alert("ajax error");
         }
      });      
    });
  
    //IE
    if(window.attachEvent){
      $("#sendMessageText").get(0).attachEvent("onpropertychange",function (o){
         if(o.srcElement.value) $( "#send_button" )[0].disabled=false;
         else $( "#send_button" )[0].disabled=true;
      });
      //非IE
    }else{
      $("#sendMessageText").get(0).addEventListener("input",function(o){
        if(o.srcElement.value) $( "#send_button" )[0].disabled=false;
        else $( "#send_button" )[0].disabled=true;
      },false);
    }
});
</script>
</body>
</html>
